import {
	getCarDetailAPI
} from "@/api/api/car.js"
let plugins = {
	install(Vue) {
		Vue.prototype.$showModal = function(content, sureCallback = function() {}, showCancel = false,
			confirmText =
			"确定", cancelText = "取消", cancelCallback = function() {}) {
			uni.showModal({
				title: '提示',
				content: content,
				showCancel: showCancel,
				confirmText: confirmText,
				cancelText: cancelText,
				success(res) {
					if (res.confirm) {
						sureCallback();
					} else if (res.cancel) {
						cancelCallback();
					}
				}
			});
		}

		Vue.prototype.$showToast = function(title, icon = 'none', mask = true) {
			uni.showToast({
				icon: icon,
				title: title,
				mask: mask
			})
		}
		
		Vue.prototype.$reLaunch = function(url) {
			uni.reLaunch({
				url: url
			});
		}
		
		Vue.prototype.$navigateTo = function(url) {
			uni.navigateTo({
				url: url
			});
		}

		Vue.prototype.$validatenull = function(val) {
			// 特殊判断
			if (val && parseInt(val) === 0) return false;
			if (typeof val === 'boolean') {
				return false;
			}
			if (typeof val === 'number') {
				return false;
			}
			if (val instanceof Array) {
				if (val.length === 0) return true;
			} else if (val instanceof Object) {
				if (JSON.stringify(val) === '{}') return true;
			} else {
				if (
					val === 'null' ||
					val == null ||
					val === 'undefined' ||
					val === undefined ||
					val === '' || val.trim() === ''
				) {
					return true;
				}
				return false;
			}
			return false;
		}
	}


}

export default plugins
